package com.itheima.sh;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.web.client.RestTemplate;
@Primary //用于解决引用容器中类 爆红的问题
@SpringBootApplication
@EnableDiscoveryClient //注册到 eureka中
@EnableFeignClients(basePackages = "com.itheima.sh.clients") //消费端用于支持扫描 到 Feign 生成伪装代理类的注解
@EnableCircuitBreaker //用于支持hystrix熔断
//@SpringCloudApplication 该注解可以代替上面三个注解
public class ConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
        System.out.println("==========消费者consumer启动==========");
    }

    // 注册RestTemplate的对象到Spring的容器中
    @Bean
    @LoadBalanced //Ribbon 负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}
